package ai.yue.open.service.cd.controller;

import ai.yue.library.base.annotation.ApiVersion;
import ai.yue.library.base.ipo.ValidationGroups;
import ai.yue.library.base.view.Result;
import ai.yue.open.service.cd.ipo.ConfRancherIPO;
import ai.yue.open.service.cd.service.ConfRancherService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@ApiVersion
@AllArgsConstructor
@RestController
@RequestMapping("/auth/{version}/confRancher")
public class ConfRancherController {

    ConfRancherService confRancherService;

    @PostMapping("/insert")
    public Result<?> insert(ConfRancherIPO confBearerTokenIPO) {
        return confRancherService.insert(confBearerTokenIPO);
    }

    @DeleteMapping("/deleteById")
    public Result<?> deleteById(Long id) {
        return confRancherService.deleteById(id);
    }

    @DeleteMapping("/deleteByIds")
    public Result<?> deleteByIds(List<Long> ids) {
        return confRancherService.deleteByIds(ids);
    }

    @PutMapping("/updateById")
    public Result<?> updateById(@Validated(ValidationGroups.Update.class) ConfRancherIPO confRancherIPO) {
        return confRancherService.updateById(confRancherIPO);
    }

    @GetMapping("/page")
    public Result<?> page() {
        // 前端需要传规范的分页参数，框架会自动从request中获取
        return confRancherService.page();
    }

    @GetMapping("/listNamespace")
    public Result<?> listNamespace() {
        return confRancherService.listNamespace();
    }

}
